package com.sun.showcase.controller.testcase;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sun.showcase.biz.testcase.service.CaseModuleService;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Json;
import com.sun.showcase.client.testcase.domain.CaseModule;
import com.sun.showcase.client.testcase.query.CaseModuleQuery;

@Controller
@RequestMapping(value="/testcase/caseModule") 
public class CaseModuleController{
	
	@Autowired
	private CaseModuleService caseModuleService;
	
	private Json json = new Json();
	/**
	 * 跳转到CaseModule管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goCaseModule")
	public String goCaseModule() {
		return "testcase/caseModule";
	}
	/**
	 * 跳转到CaseModule新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleCaseModule")
	public String handleCaseModule(@RequestParam(value="id",required=false) Long id ,ModelMap map) {
		return "testcase/caseModule_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public CaseModule showDesc(CaseModuleQuery caseModuleQuery) {
		return caseModuleService.get(caseModuleQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(CaseModuleQuery caseModuleQuery) {
		return caseModuleService.datagrid(caseModuleQuery);
	}
	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/listAll")
	public List<CaseModuleQuery> listAll(CaseModuleQuery caseModuleQuery) {
		return caseModuleService.listAll(caseModuleQuery);
	}
	

	/**
	 * 添加一个CaseModule
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Json add(CaseModuleQuery caseModuleQuery) {
		caseModuleService.add(caseModuleQuery);
		json.setSuccess(true);
		json.setMsg("添加成功！");
		return json;
	}

	/**
	 * 编辑CaseModule
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Json edit(CaseModuleQuery caseModuleQuery) {
		caseModuleService.update(caseModuleQuery);
		json.setSuccess(true);
		json.setMsg("编辑成功！");
		return json;
	}

	/**
	 * 物理删除CaseModule
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Json delete(CaseModuleQuery caseModuleQuery) {
		caseModuleService.delete(caseModuleQuery.getIds());
		json.setSuccess(true);
		json.setMsg("删除成功！");
		return json;
	}
	
	/**
	 * 逻辑删除CaseModule
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Json deletePt(CaseModuleQuery caseModuleQuery) {
		caseModuleService.deletePt(caseModuleQuery.getIds());
		json.setSuccess(true);
		json.setMsg("删除成功！");
		return json;
	}
}
